package org.water.common.api;


import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import org.water.base.entity.R;
/**
 * 统一消息返回处理
 * @author qzy
 *
 */
@RestControllerAdvice
@ControllerAdvice
public class ApiResponseBody implements ResponseBodyAdvice<Object> {

	/**
	 * 返回处理
	 */
	@Override
	public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType,
			Class<? extends HttpMessageConverter<?>> messageConverter, ServerHttpRequest request, ServerHttpResponse response) {
		
		return body;
	}

	/**
	 * 判断拦截内容
	 */
	@Override
	public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> messageConverter) {
		
		return true;
	}

}
